import { DelegateTaskData } from "./DelegateTaskData";
import { CopyUtil } from "../../copy/CopyUtil";
import { Cache } from "../../../cache/Cache";
import { ECopyType } from "../../../../../Message/Public/ECopyType";
import { EPrictUnit } from "../../../../../Message/Public/EPrictUnit";
import { SPlayerDelegate } from "../../../../../Message/Game/SPlayerDelegate";
import { TCopy } from "../../../../../Message/Db/Tables/TCopy";
type int = number;
//class CanDelegateItemData
    
    export  class CanDelegateItemData
    {
        

        public set data(arg1: DelegateTaskData)
        {
            var loc1=0;
            this._data = arg1;
            if (arg1) 
            {
                if (arg1.copy) 
                {
                    loc1 = CopyUtil.getCopyNumByDay(arg1.copy) - Cache.instance.copy.getHasEnterNumById(arg1.copy.code);
                    this._count = loc1 < 1 ? 1 : loc1;
                }
            }
            return;
        }

        public get data(): DelegateTaskData
        {
            return this._data;
        }

        public get delegateLevel(): int
        {
            if (this.copy && this.copy.copyType == ECopyType._ECopyCoin) 
            {
                return this.copy.enterMinLevel + 20;
            }
            if (this.copy && this.copy.copyType == ECopyType._ECopyDefense) 
            {
                return 60;
            }
            if (this.copy && this.copy.copyType == ECopyType._ECopy60Defense) 
            {
                return 70;
            }
            if (this.copy && this.copy.copyType == ECopyType._ECopyCrossDefense) 
            {
                return this.copy.enterMinLevel + 20;
            }
            if (this.moneyType != EPrictUnit._EPriceUnitCoin) 
            {
                if (this.moneyType == EPrictUnit._EPriceUnitGold) 
                {
                    if (this.copy) 
                    {
                        return this.copy.enterMinLevel;
                    }
                }
            }
            else if (this.copy) 
            {
                return this.copy.enterMinLevel + 10;
            }
            return 0;
        }

        public isReachLevel(): Boolean
        {
            var loc1=Cache.instance.role.roleInfo.level;
            if (this.data.tdelegate) 
            {
                return loc1 >= this.delegateLevel;
            }
            if (this.data.tsweepUp) 
            {
                if (this.moneyType == EPrictUnit._EPriceUnitCoin) 
                {
                    return loc1 >= this.data.tsweepUp.levelLimit;
                }
                return loc1 >= this.data.copy.enterMinLevel;
            }
            return false;
        }

        public isReachFightCap(): Boolean
        {
            var loc1=parseInt(Cache.instance.role.combatCapabilities);
            if (this.moneyType != EPrictUnit._EPriceUnitCoin) 
            {
                if (this.moneyType == EPrictUnit._EPriceUnitGold) 
                {
                    if (this._data) 
                    {
                        return loc1 >= this._data.tdelegate.warfareGold;
                    }
                }
            }
            else if (this._data) 
            {
                return loc1 >= this._data.tdelegate.warfareCoin;
            }
            return false;
        }

        public get copyNumOver(): Boolean
        {
            var loc1=0;
            var loc2=0;
            if (this.copy) 
            {
                loc1 = Cache.instance.copy.getHasEnterNumById(this.copy.code);
                loc2 = Cache.instance.copy.getTotalEnterNumById(this.copy.code);
                if (loc1 >= loc2) 
                {
                    return true;
                }
                return false;
            }
            return false;
        }

        public get myDelegate(): SPlayerDelegate
        {
            if (this._data) 
            {
                return Cache.instance.delegateTask.getMyDelegate(this._data.code);
            }
            return null;
        }

        public get isDelegating(): Boolean
        {
            return !(this.myDelegate == null);
        }

        public get copyLevel(): int
        {
            return this.copy ? this.copy.enterMinLevel : 0;
        }

        public set count(arg1: int)
        {
            this._count = arg1;
            return;
        }

        public get count(): int
        {
            return this._count;
        }

        public get copy(): TCopy
        {
            return this.data.copy;
        }

        public /* var */moneyType: int;

        /* internal */ /* var */_count: int;

        /* internal */ /* var */_data: DelegateTaskData;
    }
